package com.cpi.cornpp.futurepurchase.helper;

import java.util.ArrayList;

import com.cpi.cornpp.futurepurchase.view.YearView;
import com.cs.common.init.SystemParameterCollection;
import com.cs.common.init.beans.SystemParameterBean;
import com.cs.common.utils.TimeUtils;

public class FuturePurchaseHelper {

	/** Numero de anos hacia adelante que muestra el listado de ano**/
	private static int forwardYears;
	/** Nombre de parametro forwardYears**/
	private static final String TOP_FORWARD_YEARS = "TOP_FORWARD_YEARS";//$NON-NLS-1$
	/** Lista de anos futuros**/
	private static ArrayList forwardYearList = null;

	/**
	 * Devuelve la lista de anos futuros a mostrar.
	 * la lista se compone desde el ano actual hasta
	 * el ano limite definido en un parametro del sistema
	 * @return
	 */
	public static ArrayList getForwardYearList(){
		if(forwardYearList!=null)
			return forwardYearList;
		SystemParameterCollection systemParameterCollection = null;
		SystemParameterBean systemParameterBean = null;
		forwardYearList = null;
		int currentYear = 0;
		System.out.println("");
		systemParameterCollection = SystemParameterCollection.getInstance();
		systemParameterBean = systemParameterCollection.getSystemParameterBean(TOP_FORWARD_YEARS);
		forwardYears = systemParameterBean.getIntValue();
		currentYear = TimeUtils.getCurrentYear();
		forwardYearList = new ArrayList(0);
		for(int i = 0; i <= forwardYears; i++){
			forwardYearList.add(new YearView(currentYear + i,currentYear + i));
		}
		return forwardYearList;
		
	}
}
